from selenium.webdriver.common.by import By
from utils.page_webBase import PageBaseWeb

class PageForm(PageBaseWeb):
    url="http://oss.52studyit.net/webzdh/form.html"
    loc_zanhao=By.ID,"username"
    loc_pwd=By.ID,"pwd"
    loc_name="sex"
    loc_guoji="guoji"
    loc_aihao="aihao"
    loc_degree="degree"
    loc_jiesao=By.ID,"jiesao"
    loc_zaopian=By.ID,"zaopian"

    def __init__(self,driver):
        PageBaseWeb.__init__(self,driver)

    def openUrl(self):
        self.open(PageForm.url)

    def input_zanhao(self,zanhao):
        self.input(PageForm.loc_zanhao,zanhao)

    def input_pwd(self,pwd):
        self.input(PageForm.loc_pwd,pwd)

    def selectSex(self,sex):#"M" "F"
        self.click_radio(PageForm.loc_name,sex)

    def selectGuoji(self,guoji):#"zonguo"
        self.click_radio(PageForm.loc_guoji,guoji)

    def selectAihao(self,aihaos):#"dalanqiu,tizuqiu"
        self.click_checkbox(PageForm.loc_aihao,aihaos)

    def selectDegree(self,degee):#"硕士"
        self.click_select(PageForm.loc_degree,degee)

    def inputJiesao(self,jiesao):#"你好啊，我是张三\n我今年18岁"
        self.input(PageForm.loc_jiesao,jiesao)

    def uploadZaipian(self,zaopianPaths):#例如:"C:\A\1.png,C:\A\2.png"或"C:\A\1.png" 或""
        self.uploadMulFile2(PageForm.loc_zaopian,"C:/D/uploadMulFile.exe",zaopianPaths)

    def inputBirthday(self,birthday):#"2023-01-01"
        js=f"document.getElementById('birthday').value='{birthday}'"
        self.driver.execute_script(js)
